/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.Expression;

/**
 *
 * @author Administrator
 */
@Stateless
public class TestFacade extends AbstractFacade<Test> {

    @PersistenceContext(unitName = "WebApplication1PU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public TestFacade() {
        super(Test.class);
    }

    public Test findByName(String name) {
        try {
            return (Test) em.createNamedQuery("Test.findByName").setParameter("name", name).getSingleResult();
        } catch (Exception e) {
            return null;
        }
    }

    public Test findByCMND(int cmnd) {
        try {
            return (Test) em.createNamedQuery("Test.findByCmnd").setParameter("cmnd", cmnd).getSingleResult();
        } catch (Exception e) {
            return null;
        }
    }
}
